﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ymca.WebSecurity
{
	class DataContext: DbContext, IDataContext
	{
		public DbSet<User> Users { get; set; }
		public DbSet<Role> Roles { get; set; }
        public DbSet<UserToRole> UsersToRoles { get; set; }

		public DataContext()
			: base("YmcaSecurityConnectionString")
		{
			Configuration.LazyLoadingEnabled = false;
		}

		public void Save()
		{
			SaveChanges();
		}

		protected override void Dispose(bool disposing)
		{
			Save();
			base.Dispose(disposing);
		}
	}
}
